﻿using System;

class Soulution
{
    static void Main(string[] args)
    {
        Clock Clock = new Clock(DateTime.Now.AddSeconds(10));
        Clock.Tick += OnTick;
        Clock.Alarm += OnAlarm;
        Clock.Start();
        Console.ReadLine();
    }

    static void OnTick(object sender, EventArgs e)
    {
        Console.WriteLine("Tick...");
    }
    static void OnAlarm(object sender, EventArgs e)
    {
        Console.WriteLine("时间到");
    }
}

class Clock
{

    public event EventHandler Tick;
    public event EventHandler Alarm;
    private DateTime alarmTime;
    public Clock(DateTime alarmTime)
    {
        this.alarmTime = alarmTime;
    }

    public void Start()
    {
        Console.WriteLine($"闹钟已启动，闹铃时间:{alarmTime} ");

        while (DateTime.Now < alarmTime)
        {
            OnTick();
            Thread.Sleep(1000);
        }
        OnAlarm();
    }

    public virtual void OnTick()
    {
        Tick?.Invoke(this, EventArgs.Empty);
    }

    public virtual void OnAlarm()
    {
        Alarm?.Invoke(this, EventArgs.Empty);
    }
}